<template>
  <div id="app">
    <BasicLayOut />
  </div>
</template>

<style></style>
<script setup lang="ts">
import BasicLayOut from "@/layouts/BasicLayOut.vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import accessEnum from "@/access/accessEnum";

const router = useRouter();
const store = useStore();

//路由守卫，鉴权需要跳转的页面是否是当前权限能进入的页面
router.beforeEach(async (to, from, next) => {
  if (to.meta?.access === accessEnum.Admin) {
    if (store.state.userInfo?.userRole !== accessEnum.Admin) {
      next("/auth");
      return;
    }
  }
  next();
});
</script>
